package com.mtw.bbs.gateway.feign;



import com.mtw.bbs.common.core.security.UserDetails;
import com.mtw.bbs.common.core.vo.Result;
import com.mtw.bbs.gateway.config.FeignInterceptor;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashMap;

/**
 * 鉴权 Feign接口类
 */
@FeignClient(name = "bbs-auth",contextId = "authClient",configuration = FeignInterceptor.class,fallback = AuthClientFallback.class)
public interface AuthClient {



    /**
     * 鉴权
     */
    @ApiOperation(value = "请求鉴权", notes = "传入url和请求方式")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "token", value = "token", required = true, dataType = "string")
    })
    @GetMapping("/permission")
    Result<UserDetails> permission(@RequestBody HashMap<String,Object> params);



    /**
     * 鉴权
     */
    @ApiOperation(value = "token合法性验证", notes = "token")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "token", value = "token", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "url", value = "访问的url", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "method", value = "请求方式", required = true, dataType = "string")
    })
    @GetMapping("/validate")
    Result<UserDetails> validate(@RequestBody HashMap<String,Object> params);



}
